<?php

$idCliente = $this->uri->segment(3);

$query = $this->clientemodel->buscarClientePorId($idCliente)->row();?>


<div class="span10">
		  <div class="row-fluid">
			<div class="page-header">
				<h1><?=$titulo;?></h1>
                                
			</div>
			<?php $atributos_formulario = array('id'=>'exm1','role'=>'form','onsubmit'=>'PreventMultipleSubmit()','class'=>'form-inline');
                            echo form_open_multipart ("clientecontroller/do_upload/$idCliente",$atributos_formulario);
                            echo form_input(array('name'=>'idCliente', 'id'=>'idCliente', 'type'=>'hidden','class'=>'input-large ','placeholder'=>'Data Próxima Consulta','value'=>$idCliente), set_value($idCliente));
                                   
                            if(validation_errors())
                            {?>
                                <div class="alert alert-danger">
                                    <button type="button" class="close " data-dismiss="alert">&times;</button>
                                    <span><?=validation_errors();?></span>
                                </div>
                            <?php                            
                            }
                            
                             if($this->session->flashdata('cadastrook')){?>
                                <div class="alert alert-success">
                                    <button type="button" class="close " data-dismiss="alert">&times;</button>
                                    <p><?=$this->session->flashdata('cadastrook');?></p>
                                </div>
                             <?php
                            }
                      if($this->upload->display_errors())
                            {?> <div class="alert alert-danger">
                                    <button type="button" class="close " data-dismiss="alert">&times;</button>
                                    <p><?=$error;?></p>
                                </div>
                                    <?php
                             }else if($ok != '')
                             {?> <div class="alert alert-success">
                                    <button type="button" class="close " data-dismiss="alert">&times;</button>
                                    <p><?=$ok;?></p>
                                 </div>
                                <?php
                              }?>
                      
                         
                      <div style="float: left; padding: 10px; border-right: 0px solid #f89406;">
                     
                          <h2>Escolha a Imagem: </h2>
                          <hr />
                              <div class="input-prepend">
                                        <span class="add-on ticket">Foto</span>
                                           <?php $arquivo = array('name' => 'userfile', 'id' => 'userfile');
                                                echo form_upload($arquivo);?>
                                                
                                                
					</div><br><br>
                           

					<div class="form-actions">
						<button type="submit" id="btSubmit" class="btn btn-primary pull-left"> Enviar</button>
                                          <button type="reset" id="carregando" class="btn btn-slate-action pull-left x" disabled="disabled"> Aguarde ...</button>
                                          
                                       
                                         <?php 
                                    $image_properties = array(
                                    'src' => 'img/loading.gif',
                                    'alt' => 'avatar',
                                    'class' => 'img-responsive imageborder x',
                                    'width' => '104',
                                    'height' => '45',
                                    'title' => '',
                                    'id' => 'carregando',                                    
                                    );                                    
                                    echo img($image_properties);?>
                                          &nbsp;
                                                <?=anchor(base_url()."clientecontroller/listarCliente","Cancelar",array('class'=>'btn'));?>                                                
					</div>					
				</form>
                      </div>
                       <div style="float: left; padding: 10px; width: 700px;">
                          <div style="float: right; padding: 10px;">
                               <?php       $imagem = array(
                                            'src' => "img/fotos/".$query->foto,
                                            'class' => 'thumbnail',
                                            'width' => '100',
                                            'height' => '120',
                                            );?>
											 
                                        <?=img($imagem);?>
                          </div>
                          <div style="padding: 10px; float: right">
                              <h3>Nome: <?=$query->nome;?></h3>
                              <h3>Data de Nascimento: <?=$query->dataNascimento;?></h3>
                          <h3>Telefone: <?=$query->telefone;?></h3>
                          <h3>Cpf: <?=$query->cpf;?></h3>
                          <h3>Data Incío Tratamento: <?=$query->dataInicioTratamento;?></h3>
                          </div> 
                      </div> <br clean="both"  />               
                        
                        
		  </div>
    <h2>Lista de Imagens:</h2>
    <hr />
    <?php
    $buscaImagem = $this->clientemodel->buscarImagemCliente($query->id_cliente)->result(); 
        
        foreach ($buscaImagem as $imagem)
        {   ?>
    <div style="float: left; padding: 5px">
        <?php
            $img = array(
            'src' => "img/fotos/".$imagem->foto,
            'class' => 'thumbnail',
            'width' => '100',
            'height' => '120',
            );
            echo img($img);
            ?>
        <?=anchor(base_url()."clientecontroller/remover/".$imagem->id_imagem,"<i class='icon icon-remove'></i> Excluir",array('class'=>'label label-warning'));?>
        
         </div>   
    
        <?php } ?>   
                                   
</div>
    

 <script type="text/javascript">
        function PreventMultipleSubmit(){
            document.getElementById("btSubmit").disabled = true;       
            document.getElementById("btSubmit").style.display = "none";
            document.getElementById("carregando").style.display = "block";        
        }
  </script>
     